<template>
    <uni-popup ref="popup" type="dialog">
        <uni-popup-dialog
            type="error"
            title="提示"
            mode="base"
            cancelText="暂不登录"
            confirmText="立即登录"
            :duration="2000"
            :before-close="true"
            @close="close"
            @confirm="confirm"
        >
            <div style="font-size: 26rpx; color: #6c6c6c">{{ CLogin.dialog.content }}</div>
        </uni-popup-dialog>
    </uni-popup>
</template>

<script lang="ts" setup>
import { ref, watch } from 'vue'
import CLogin from '~/store/CLogin'
import System from '~/utils/System'
import Timer from '~/utils/Timer'
const popup = ref({} as any)

const open = () => {
    popup.value.open()
    CLogin.dialog.show = true
}

const close = () => {
    popup.value.close()
    CLogin.dialog.show = false
}
const confirm = () => {
    close()
    Timer.once(() => {
        System.navigateTo('/login')
    }, 300)
}

watch(
    () => CLogin.dialog.show,
    (val) => {
        if (val) open()
        else close()
    }
)
</script>
